Conversation
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
Great job on this submission! The server is well-structured and correctly uses streams for processing. However, a change is needed to meet all the requirements.
The primary issue is that the compressed file names have the wrong extensions.
- Required:
.gzforgzipand.dflfordeflate. - Current:
.gzipand.deflate.
Please update the logic in src/createServer.js to map the compressionType to the correct extension when you set the Content-Disposition header.
As a minor improvement, you could also add the required attribute to the <select> element in src/index.html for better client-side validation. After you fix the file extension issue, I'll be happy to approve your work!
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
Important
Fix the issues, commit the changes, and then re-request my review using the Re-request review button2 in the Reviewers tab.
Tip
If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.
Caution
Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.
Footnotes
|
|
||
| res.writeHead(200, { | ||
| 'Content-Type': contentType, | ||
| 'Content-Disposition': `attachment; filename=${filename}.${compressionType}`, |
There was a problem hiding this comment.
The task description specifies the file extensions should be .gz for gzip and .dfl for deflate. Currently, you are using the compressionType variable directly, which results in .gzip and .deflate extensions. You should map the compression type to the correct extension.
| method="POST" | ||
| enctype="multipart/form-data" | ||
| > | ||
| <select name="compressionType"> |
There was a problem hiding this comment.
Consider adding the required attribute to this select element. This would prevent the form from being submitted if the user hasn't chosen a compression type, which improves the user experience by providing instant client-side validation.
| <title>Document</title> | ||
| </head> | ||
| <body> | ||
| <form action="http://localhost:5700/compress" |
There was a problem hiding this comment.
The action attribute is hardcoded to a specific URL. It's better practice to use a relative path like /compress to make the form independent of the server's host and port. Additionally, please note that the server implementation is configured to serve the file located at src/index.html, not this one.
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
Great job on fixing the server-side logic for file extensions from the last review!
However, this submission requires changes because the core compression functionality is broken for gzip and deflate. There is a mismatch between the values sent from your HTML form and the values your server expects.
- In
src/index.html, the<option>tags for gzip and deflate havevalue="gz"andvalue="dfl". - Your server logic in
src/createServer.jscorrectly expects the full names:"gzip"and"deflate".
This causes the server to reject these requests with an 'Unsupported compression type' error. Please update the value attributes in src/index.html to match the full names. Once that's fixed, your project should be all set!
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
Important
Fix the issues, commit the changes, and then re-request my review using the Re-request review button2 in the Reviewers tab.
Tip
If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.
Caution
Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.
Footnotes
src/index.html
Outdated
| <option value="gz">gzip</option> | ||
| <option value="dfl">deflate</option> | ||
| <option value="br">br</option> |
There was a problem hiding this comment.
The value attributes for these options should be gzip, deflate, and br respectively. The server-side logic in createServer.js checks for these full names to determine which compression algorithm to use. Currently, you are sending the extensions (gz, dfl), which will cause the server to respond with an 'Unsupported compression type' error.
| if (compressionType === 'gzip') { | ||
| compressStream = zlib.createGzip(); | ||
| contentType = 'application/gzip'; | ||
| } else if (compressionType === 'deflate') { | ||
| compressStream = zlib.createDeflate(); | ||
| contentType = 'application/zlib'; | ||
| } else if (compressionType === 'br') { | ||
| compressStream = zlib.createBrotliCompress(); | ||
| contentType = 'application/brotli'; | ||
| } else { | ||
| res.statusCode = 400; | ||
|
|
||
| return res.end('Unsupported compression type'); | ||
| } |
There was a problem hiding this comment.
This block correctly checks for 'gzip', 'deflate', and 'br'. However, the src/index.html file is sending different values ('gz', 'dfl') from its form for gzip and deflate options. This mismatch will cause requests for gzip and deflate compression to fail with an 'Unsupported compression type' error. Please ensure the value attributes in the <option> tags in src/index.html match the values expected by the server.
No description provided.